<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <h1>身体健康指数</h1>
    <form action="">
        <input type="text" name="height" placeholder="身高(米)">
        <input type="text" name="weight" placeholder="体重(公斤)">
        <input type="button" value="测试" @click="test()">
        <h1>测试结果:{{info}}</h1>
    </form>
<!--引入axios和vue-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script>
        let v = new Vue({
            el:"form",
            data:{
                info:""
            },
            methods:{
                test:function () {
                    //发起异步请求
                    let data = new FormData(document.querySelector("form"));
                    axios.post("/test",data).then(function (res) {
                        //把服务端返回的数据直接显示到页面中
                        v.info = res.data;
                    })
                }
            }
        })
    </script>


</body>
</html>